
function addOrUpdRuleGroupWin(id, title) {
	var addOrUpdRuleGroupForm = new Ext.form.FormPanel({
		id : 'addOrUpdRuleGroupForm',
		frame : true,
		//layout : "form",
		buttonAlign : 'center',
		monitorValid : true,
		bodyBorder : false,
		fileUpload : true,// 上传文件设置为true
		reader : new Ext.data.JsonReader({
					success : 'success',
					root : 'data'
				}, [{
							name : "id"
						}, {
							name : "ruleGroupName"
						}, {
							name : "isEnable"
						}, {
							name : "createdDate"
						}, {
							name : "createdName"
						}]),

		items : [{
					layout : 'form',
					border : false,
					labelWidth:60,
					items : [{
								xtype : 'hidden',
								name : 'id',
								value : id
							}, {
								xtype : 'textfield',
								anchor : '100%',
								labelStyle : "text-align:right;",
								fieldLabel : "<span style='color:#F00'>*</span>规则名称",
								allowBlank : false,
								name : "ruleGroupName"
							}, {
								id:'ruleGroupForm_isEnable',
								xtype : 'localcommonbox',
								anchor : '100%',
								labelStyle : "text-align:right;",
								fieldLabel : "<span style='color:#F00'>*</span>是否可用",
								hiddenName : "isEnable",
								allowBlank : false,
								loaclarr : [['0', '可用'], ['1', '不可用']],
								value : 0
							}]
				}],
		buttons : [{
					text : '确定',
					formBind : true,
					handler : function() {
						addOrUpdRuleGroup();
					}
				}, {
					text : "取消",
					handler : function() {
						addOrUpdRuleGroupWindow.close();
					}
				}]
	});
	var addOrUpdRuleGroupWindow = new Ext.Window({
				id : 'addOrUpdRuleGroupWindow',
				closeAction : 'destroy',
				title : title,
				closable : true,
				plain : true,
				modal : true,
				draggable : false, // 不可拖动
				resizable : false, // 不可调整
				width : 280,
				height : 150,
				buttonAlign : 'center',
				autoDestroy : true,
				layout : 'fit',
				items : [addOrUpdRuleGroupForm],
				listeners : {
					'show' : function() {
						queryRuleGroupById(id);
					},
					'beforeshow' : function() {
						addOrUpdRuleGroupWindow.center();
					}
				}
			});
	return addOrUpdRuleGroupWindow;

};

/**
 * 查询规则组信息
 * @param {}
 * id
 */
function queryRuleGroupById(id) {
	if (id != null && id != "undefined") {
		Ext.getCmp("addOrUpdRuleGroupForm").getForm().load({
					// deferredRender : false,
					url : __ctxPath + "/couponRuleManager/queryRuleGroupById",
					params : {
						id : id
					},
					method : "POST",
					waitTitle : "请稍候",
					waitMsg : "正在载入数据...",
					root : "data",
					success : function(form, action) {
						var data = action.result.data;
					},
					failure : function(f, g) {
						Ext.MessageBox.show({
									title : "操作信息",
									msg : "数据加载失败!",
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.ERROR
								});
					}
				});
	}
}

/**
 * 修改规则组信息
 */
function addOrUpdRuleGroup() {
	var ruleGroupForm = Ext.getCmp("addOrUpdRuleGroupForm");
	if (ruleGroupForm.getForm().isValid()) {
		Ext.Msg.confirm("提示框", "确认要保存规则组信息吗?", function(button) {
					if (button == "yes") {
						ruleGroupForm.getForm().submit({
							url : __ctxPath
									+ '/couponRuleManager/addOrUpdRuleGroup',
							waitTitle : "请稍候",
							waitMsg : "正在提交表单，请稍候......",
							failure : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "错误提示",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.ERROR
										});
							},
							success : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "信息提示",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.INFO
										});
								Ext.getCmp("addOrUpdRuleGroupWindow").close();
								var gridPanel = Ext.getCmp('ruleGroupGrid');
								if (typeof(gridPanel) != 'undefined') {
									gridPanel.store.reload();
								}
							}
						});
					}
				});
	}
}